﻿<Window x:Class="Brjnk.GpxExplorer.UI.CreateWaypointWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:Brjnk.GpxExplorer.Localization"
        Title="{l:Loc titleCreateWaypoint}"
        MinWidth="300"
        DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
        FocusManager.FocusedElement="{Binding ElementName=txbName}"
        SizeToContent="WidthAndHeight"
        WindowStartupLocation="CenterOwner">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Row="0"
                   Grid.ColumnSpan="2"
                   Text="{l:Loc createWaypointName}" />
        <TextBox Name="txbName"
                 Grid.Row="1"
                 Grid.ColumnSpan="2"
                 Style="{StaticResource HeaderTextBoxStyle}"
                 Text="{Binding PointName, UpdateSourceTrigger=PropertyChanged}" />
        <TextBlock Grid.Row="2"
                   Grid.ColumnSpan="2"
                   Text="{l:Loc createWaypointPosition}" />
        <TextBox Name="coordinatesTxb"
                 Grid.Row="3"
                 Grid.ColumnSpan="2"
                 Text="{Binding Coordinates}" />
        <Button Grid.Row="4"
                HorizontalAlignment="Right"
                Click="Button_Click"
                Content="{l:Loc cancel}"
                IsCancel="True" />
        <Button Name="okButton"
                Grid.Row="4"
                Grid.Column="1"
                HorizontalAlignment="Right"
                Click="Button_Click_1"
                Content="{l:Loc ok}"
                IsDefault="True">
            <Button.Style>
                <Style BasedOn="{StaticResource ResourceKey={x:Type Button}}" TargetType="Button">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=txbName, Path=(Validation.HasError)}" Value="true">
                            <Setter Property="IsEnabled" Value="False" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=coordinatesTxb, Path=(Validation.HasError)}" Value="true">
                            <Setter Property="IsEnabled" Value="False" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
    </Grid>
</Window>